<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 								
	<head> 							
		<%@ include file="../jslib/jquerylib.jsp" %>
		 <link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jqGrid/css/jqgrid.css"></link>
	    <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/lhgdialog/lhgcore.lhgdialog.min.js?skin=mac"></script>
	        <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/My97DatePicker/WdatePicker.js" defer="defer"></script>
        <link href="<%=request.getContextPath() %>/web/style/layout.css" type="text/css" rel="stylesheet"/>
        <link rel="stylesheet" href="<%=request.getContextPath() %>/jslib/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css"/>
        <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/ztree/jquery.ztree.core-3.4.js"></script>
	       <!-- 删除结果信息返回 -->
	    	<c:if test="${requestScope.message!=null}">
				<script type="text/javascript">
	  	 		     alert('<c:out value="${requestScope.message}"></c:out>');
	  	 		     window.close();
	  			</script>
	        </c:if>
	 
	<script type="text/javascript">
			var flowid = '2541';
			$(document).ready(function(){
					$("#gridTable").jqGrid({
						url:'<%=request.getContextPath() %>/junyansAction!queryJunyans.action',
						datatype: "json",
						height: 450,
						width: 710, 
						autowidth: true, 
						colNames:['序号','任务编号','产品代号','试验类型','负责人','试验地点','涉密等级','试验开始时间','预计结束时间','阶段类型','计划用弹量'],
						colModel:[
								{name:'ID',index:'ID', width:60, key:true, sorttype:"int",hidden:true,hidedlg:true}, 
								{name:'renwubh',index:'renwubh', width:100},								
								{name:'chanpindh',index:'chanpindh', width:80},
								{name:'shiyanlx',index:'shiyanlx', width:110},
								{name:'fuzher',index:'fuzher', width:110},
								{name:'shiyandd',index:'shiyandd', width:110},
								{name:'shemidj',index:'shemidj', width:80},
								{name:'shiyankssj',index:'shiyankssj', width:110},
								{name:'yujijssj',index:'yujijssj', width:110},
								{name:'jieduanlx',index:'jieduanlx', width:80},
								{name:'jihuaydl',index:'jihuaydl', width:80}
					],
					shrinkToFit:false,
					sortname:'ID',
					sortorder:'desc',
					viewrecords:true,
					multiselect: true, // 是否显示复选框
					multiboxonly : true, 
					//gridview: true,  //提升速度
					rownumbers: true,//显示行号
					rownumWidth: 30, //行号的宽度
					rowNum:15,
					rowList:[15,20,50,200,500],
					toolbar: [false,"top"],
					jsonReader: {
						root:"rows",		// 数据行（默认为：rows）
						page: "page",  	// 当前页
						total: "total",  // 总页数
						records: "records",  // 总记录数
						repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设
					},
					prmNames:{rows:"rows",page:"page",sort:"sidx",order:"sord",search:"search"},
					pager:"#gridPager",
					caption: "试验流程"
			});
			    
				 jQuery("#gridTable").jqGrid('navGrid','#gridPager',{add:false,edit:false,del:false,search:false,refresh:false});
					jQuery("#gridTable").jqGrid('navButtonAdd','#gridPager',
								{ 	
								caption: "",                          
								onClickButton : function (){                               
								jQuery("#gridTable").jqGrid('setColumns');                           
								}
					}); 
				doResize(); 									
	}); 
	
	//执行大小
	function doResize() { 
		var ss = getPageSize(); 
		//alert(ss.WinH);
		
			 $("#gridTable").jqGrid('setGridHeight', ss.WinH-245);
			 $("#gridTable").jqGrid('setGridWidth', ss.WinW-30); 
			} 
			
    //删除 
	function delFlow(){
		var ids = $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
	    if (!ids) {
	    alert("请先选择记录!");  
	       return false;  
		} 
		if(!confirm("是否确认删除 ？")){
		   return false;
		}
		 var params = {  
			        "ids": ids
			    };  
		var actionUrl = "<%=request.getContextPath() %>/junyansAction!deleteJunyans.action?ids="+ids;  
		$.ajax({  
			  url : actionUrl,  
		      type : "post", 
		      data : params,  
		      dataType : "json",  
		      cache : false,  
		      error : function(textStatus, errorThrown) {  
		          alert("系统ajax交互错误: " + textStatus.value);  
		      },  
		      success : function(data, textStatus) {
		      	if(data.result=='success'){
		      		alert("删除成功！");       
		      		gridSearch();    
		      	}else{
		      		alert("删除失败！");
		      	}
		    }  
		});
	}
	
	 
		//修改
		function editFlow(){
			var ids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
			if (!ids) {
			    alert("请先选择记录!");  
			    return false;  
			}
			if(ids.indexOf(",")!=-1){
				  alert("只能选择一条记录!");  
			        return false; 
			}
			var row = jQuery("#gridTable").jqGrid('getRowData',ids);//获取选中行.
			var id = row.ID;//获取选中行的id属性.
			$.dialog({
		        title: '试验流程修改',
		        content: 'url:<%=request.getContextPath() %>/junyansAction!initJunyansfq.action?flowid='+flowid+'&junyansid='+id+'&temp='+Math.round(Math.random()*10000),
		        okVal: false,//确定按钮文字
		        cancelVal: false,//取消按钮文字
		        min: true, //是否显示最小化按钮
		        max: false,//是否显示最大化按钮
		        fixed: false,//开启静止定位
		        lock: true,//开启锁屏
		        focus: true,//弹出窗口后是否自动获取焦点（4.2.0新增）
		        time: null,//设置对话框显示时间
		        resize: true,//是否允许用户调节尺寸
		        drag: true,//是否允许用户拖动位置
		        cache: false,//是否缓存iframe方式加载的窗口内容页
		        width: '1000px',
		        height: 600,
		        close: function(){
		        	gridSearch();
			    }
			});
		}
		
		//查看
		function viewFlow(){
			var ids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
			if (!ids) {
			    alert("请先选择记录!");  
			    return false;  
			}
			if(ids.indexOf(",")!=-1){
				  alert("只能选择一条记录!");  
			        return false; 
			}
			var row = jQuery("#gridTable").jqGrid('getRowData',ids);//获取选中行.
			var id = row.ID;//获取选中行的id属性.
			var toUrl = "url:<%=request.getContextPath() %>/flow/FlowTypeAddView.jsp?id=2541&filename=20151103112329.xml&temp="+Math.round(Math.random()*10000);
			$.dialog({
		        title: '试验流程查看',
		        content: toUrl,
		        okVal: false,//确定按钮文字
		        cancelVal: false,//取消按钮文字
		        min: true, //是否显示最小化按钮
		        max: false,//是否显示最大化按钮
		        fixed: false,//开启静止定位
		        lock: true,//开启锁屏
		        focus: true,//弹出窗口后是否自动获取焦点（4.2.0新增）
		        time: null,//设置对话框显示时间
		        resize: true,//是否允许用户调节尺寸
		        drag: true,//是否允许用户拖动位置
		        cache: false,//是否缓存iframe方式加载的窗口内容页
		        width: '1000px',
		        height: 600
			});
		}
		
		
			//添加
		function addFlow(){ 
			$.dialog({
		        title: '试验流程添加',
		        content: 'url:<%=request.getContextPath() %>/junyansAction!initJunyansfq.action?flowid='+flowid,
		        okVal: false,//确定按钮文字
		        cancelVal: false,//取消按钮文字
		        min: true, //是否显示最小化按钮
		        max: false,//是否显示最大化按钮
		        fixed: false,//开启静止定位
		        lock: true,//开启锁屏
		        focus: true,//弹出窗口后是否自动获取焦点（4.2.0新增）
		        time: null,//设置对话框显示时间
		        resize: true,//是否允许用户调节尺寸
		        drag: true,//是否允许用户拖动位置
		        cache: false,//是否缓存iframe方式加载的窗口内容页
		        width: '1000px',
		        height: 600,
		        close: function(){
		        	gridSearch();
			    }
			});
 		}
	        
	      //页面上的刷新按钮
			function shuaXin(){
				reset();
				gridSearch();
			}
	   
		
		//查询
		function gridSearch(){
	
			var renwubh = $.trim(jQuery("#renwubh").val());
            var chanpindh = $.trim(jQuery("#chanpindh").val()); 
            var jieduanlx = $.trim(jQuery("#jieduanlx").val());
            var params = {  
                        "renwubh" : encodeURIComponent(renwubh),                           
                        "chanpindh" : encodeURIComponent(chanpindh),
                        "jieduanlx" : encodeURIComponent(jieduanlx)
                        }
            var postData = $("#gridTable").jqGrid("getGridParam", "postData");
            $.extend(postData, params);
			jQuery("#gridTable").jqGrid('setGridParam',
			{
				url:'<%=request.getContextPath() %>/junyansAction!queryJunyans.action'
			}).trigger("reloadGrid", [{page:1}]);
			
			window.parent.getInitCountlv();
        } 
       
		//刷新
		function refreshIt(){
			reset();
			gridSearch();
		}
		//清空
		function reset(){
			jQuery("#renwubh").val("");
			jQuery("#chanpindh").val("");
			jQuery("#jieduanlx").val("");
		}

	</script>	
	</head>
	<body>
	<form action="" method="post" id="form1">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
		   		<td>
			 		<table width="100%" border="0" cellspacing="0" cellpadding="0" class="font12Black_B">
			   		<tr>
			        	<td width="8%" height="35">任务编号：</td>
			        	<td width="12%"><input type="text" name="renwubh" id="renwubh" class="search_InputText" style="width:99%;"/></td>
			        	<td width="8%" height="35" align="right">产品代号：</td>
			        	<td width="12%"><input type="text" name="chanpindh" id="chanpindh"  class="search_InputText" style="width:99%;" /> </td>
			        	<td width="8%" height="35" align="right">阶段类型：</td>
			       	 	<td width="12%"><input type="text" name="jieduanlx" id="jieduanlx"  class="search_InputText" style="width:99%;" /></td>
			       	 	<td width="15%" align="center"><input type="button" name="button" id="button" value="查询" onclick="gridSearch()" class="search_Btn" />
			      			&nbsp;<input type="reset" name="button2" id="button2" value="清空" onclick="reset()" class="search_Btn" />
			      		</td>
			      	</tr>
			      </table>
			         
		  		</td>
		 	  </tr>
		      <tr>
                <td align="right" height="9" class="sclinebotBg"></td>
	          </tr>
			</table>
			<table style="width: 100%;" class="tableCont">
				<tr>
					<td height="25" valign="top">
		         	<input id="add"    type='button' value='新建流程' onclick="addFlow()" class='button_b' />
		         	<input id="update" type='button' value='修改流程' onclick='editFlow()' class='button_b' />
		         	<input id="add"    type='button' value='删除流程' onclick="delFlow()" class='button_b' />
		         	<input id="add"    type='button' value='查看流程' onclick="viewFlow()" class='button_b' />
				</tr>
				<tr>
					<td colspan="4" style="padding-top:8px;">
						<table id="gridTable"></table>
						<div id="gridPager"></div>
					</td>
				</tr>
		   </table>
	</form>
	</body>
</html>
